<?php

	/*fn get_xml{{{*/
	function get_xml($title, $data){
		$colors = array(
			'#1190FF', '#FF8C00', '#008000', '#3E3E00', '#A13800', '#00FFFF',
			'#000080', '#4682B4', '#800000', '#FF1493', '#F4A460', '#F08080',
			'#808000', '#008080', '#800080', '#DDA0DD', '#B22222', '#A4FF2F',
			'#550000', '#AA0000', '#FF0000', '#000000', '#5A3A00', '#AAAAAA',
			'#005500', '#00AA00', '#00FF00', '#000055', '#0000AA', '#0000FF',
			'#555500', '#AAAA00', '#FFFF00', '#550055', '#AA00AA', '#FF00FF',
			'#005555', '#00AAAA', '#555555',
		);
		$color_index = 0;
		$xml_data = '<chart>';
		$xml_set = '<settings> <labels> <label lid="0"> <text><![CDATA[<b>'.$title.'</b>]]></text> </label> </labels> <values> <x><frequency>2</frequency></x> </values> <grid> <x><approx_count>30</approx_count></x> </grid> <legend> <values> <width>100</width> <text><![CDATA[: {value}%]]></text> </values> </legend> <graphs>';
		foreach($data as $idx=>$one){
			foreach($one as $i=>$v) {
				$one[$i] = '<value xid="'.$i.'">'.$v.'</value>';
			}
			$tmp = ($color_index===0)
				? "<series>"
				: '<graph gid="'.($color_index-1).'">';
			array_unshift($one, $tmp);
			if($color_index==1) array_unshift($one, '<graphs>');
			$xml_data .= join($one, '') . ($color_index===0 ? '</series>' : '</graph>');
			if($color_index){
				$xml_set .= '<graph gid="'.($color_index-1).'"><axis>left</axis><title>'.$idx.'</title><color>'.$colors[$color_index-1].'</color><line_width>3</line_width><balloon_text><![CDATA[{value}%]]></balloon_text><bullet>round_outlined</bullet></graph>';
			}
			$color_index++;
		}
		return array(
			'data'	=> $xml_data . '</graphs></chart>',
			'set'	=> $xml_set . '</graphs></settings>',
		);
	}
	/*}}}*/
		/* vim: set fdm=marker tabstop=4 shiftwidth=4 softtabstop=4: */
